package com.iisigroup.tech.dev;

import java.util.Arrays;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.PropertyType;
import org.sonar.api.SonarPlugin;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.web.NavigationSection;
import org.sonar.api.web.Page;
import org.sonar.api.web.UserRole;
import org.sonar.plugins.scmstats.ScmStatsConstants; 

import com.foo.MyWidget;
import com.google.common.collect.ImmutableList;

@NavigationSection(NavigationSection.HOME)
@UserRole(UserRole.USER)
public final class MyConsolePage extends SonarPlugin implements Page {
    Logger logger = LoggerFactory.getLogger(getClass());
    public static final String ENABLED_DEFAULT = "true";
    public static final String SCMSTATS_CATEGORY = "Robert's Scm Stats";
    public static final String COMMON_SUBCATEGORY = "Common";
    public static final String PERFORCE_SUBCATEGORY = "Perforce";
    public String getId() {
        logger.info("getId()");
        return "/com/foo/my_widget.html.erb";
    }

    public String getTitle() {
        logger.info("getTitle()");
        return "Robert's  Console";
    }
    public List getExtensions() {
        logger.info("getExtensions()"); 
        return ImmutableList.of(
                PropertyDefinition.builder(ScmStatsConstants.ENABLED).
                defaultValue(MyConsolePage.ENABLED_DEFAULT).
                name("Activation of SCM Stats plugin").
                description("This property can be set to false in order to deactivate the SCM Stats plugin.").
                index(0).
                onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).
                category(SCMSTATS_CATEGORY).
                type(PropertyType.BOOLEAN).
                build(),
                
                MyConsolePage.class,
                MyConsole2Page.class,
                MyConsole3Page.class,
                MyWidget.class,
                MyExtension.class
                );
    }
}
